"""
file 工具模块
"""
def print_file_info(file_name):
    """
    打印文件信息
    :param file_name:
    :return:
    """
    f = None
    try:
        f = open(file_name,"r",encoding="utf-8")
        print("文件内容如下：")
        print(f.read())
    except Exception as e:
        print(f"出现异异常：{e}")
    finally:
        if f:
            f.close()

def append_to_file(file_name,data):
    """
    将数据追加到文件中
    :param file_name:文件名
    :param data:要追加到文件中的信息
    :return:
    """
    f = None
    try:
        f = open(file_name,"a")
        f.write(data)
    except Exception as e:
        print(f"文件不存在：{e}")
        f = open(file_name,"w")
    finally:
        f.close()





